package com.moli.iov.manager;



import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/**
 * <p>
 *
 * </p>
 *
 * @Auther: zph
 * @Date: 2018/11/26 17:28
 */
public class CustomGenerator {

    public static void main(String[] args) {
        AutoGenerator mpg = new AutoGenerator();

        //全局配置
        GlobalConfig gc = new GlobalConfig();
        
        gc.setOutputDir("D:\\generatorCode");
        gc.setFileOverride(false);
        gc.setEnableCache(false);
        gc.setActiveRecord(false);
        gc.setAuthor("fudaohui");
        mpg.setGlobalConfig(gc);

        //数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setDbType(DbType.MYSQL);
        dsc.setTypeConvert(new MySqlTypeConvert());
        dsc.setDriverName("com.mysql.jdbc.Driver");
        dsc.setUsername("testiov");
        dsc.setPassword("Qndsa3jf3w");
        dsc.setUrl("jdbc:mysql://172.16.100.71:3306/testiov?useUnicode=true&characterEncoding=utf-8&useSSL=false");
        mpg.setDataSource(dsc);

        //策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setInclude(new String[] { "tbox_upgrade_file" }); // 需要生成的表
        strategy.setTablePrefix("library_");// 此处可以修改为您的表前缀
        strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
        mpg.setStrategy(strategy);

        //包配置
        PackageConfig pc = new PackageConfig();
        pc.setParent("com.moli.iov.vehicle");
        //pc.setModuleName("test");
        mpg.setPackageInfo(pc);

        //目录配置
        TemplateConfig tc = new TemplateConfig();
        tc.setController(null);
        mpg.setTemplate(tc);

        //执行生成
        mpg.execute();
    }
}
